//
//  CALayer+Animation.m
//  GK
//
//  Created by Seven on 2018/12/21.
//  Copyright © 2018年 Seven. All rights reserved.
//

#import "CALayer+Animation.h"

@implementation CALayer (Animation)


- (CABasicAnimation *)zRotationAnimationWithCount:(NSInteger)count duration:(CGFloat)duration {
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    //默认是顺时针效果，若将fromValue和toValue的值互换，则为逆时针效果
    animation.fromValue = [NSNumber numberWithFloat:0.f];
    animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
    animation.duration = duration;
    animation.repeatCount = count; //如果这里想设置成一直自旋转，可以设置为NSIntegerMax，否则设置具体的数值则代表执行多少次
    [self addAnimation:animation forKey:nil];
    return animation;
}

@end
